#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_CommHdr.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/XyRyNet_Types.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine/NetEngine_ManagePool/ManagePool_Define.h"
#include "../../../NetEngine_Linux/NetEngine_SourceCode/NetEngine/NetEngine_ManagePool/ManagePool_Error.h"


//g++ -std=gnu++11 -Wall -g TestFor_ManngePool.cpp -o TestFor_ManngePool -L ./ -lNetEngine_BaseLib -lNetEngine_Algorithm -lNetEngine_ManagePool -Wl,-rpath=./
void fun(void *p)

{
    printf("call fun\n");
}

int main(int argc, char *const *argv)
{
    printf("%d\n",sizeof(ULONG));
    XMPOOL xmPool;
    MANAGEPOOL_MEMORY_CLEANUP *pSt_Cleanup;

    void *p1,*p2,*p3,*p4;

    xmPool = ManagePool_Memory_Create(512); /*创建pool*/

    p1 = ManagePool_Memory_Alloc(xmPool,416); /*分配内存，在可分配内*/
    memcpy(p1,"p1",2);
    printf("%s\n",p1);

    p2=ManagePool_Memory_Alloc(xmPool,200);/*分配内存，在可分配内，但pool中没有足够的内存空间*/
    memcpy(p2,"p2",2);
    printf("%s\n",p2);

    p3=ManagePool_Memory_Alloc(xmPool,624);//分配大内存
    memcpy(p3,"p3",2);
    printf("%s\n",p3);

    p4=ManagePool_Memory_Alloc(xmPool,100);//分配内存
    memcpy(p4,"p4",2);
    printf("%s\n",p4);

    pSt_Cleanup=ManagePool_Memory_CleanupAdd(xmPool, sizeof(void *));/*添加释放特殊结构体的函数*/
    pSt_Cleanup->fpCall_Cleanup=&fun;
    ManagePool_Memory_Destory(xmPool);/*pool池注销*/
    printf("\n");
    return 0;
}
